#include <iostream>
#include <filestore/bar_file.h>
#include <cppbase/logging.h>
#include <filestore/tdx_file.h>
int main1(){
    BarFile::set_rootpath("C:\\Users\\Y\\Desktop\\tmpbar");
    BarFile barf(Exchange(1), "T00001", BarSize::Min1);
    BarFile to(Exchange(1), "000001", BarSize::Min1);
    barf.print_barfile_info();
    //20050104,20210716,4019 rows
    //20200922,20210716,rowsize 6244,rowcont 150
    int index = 100;
    int count = 50;
    int cnt = count;
    int loop = 0;
    int rowsize = 6244;
    while (true) {
        loop++;
        auto ptr = barf.get_bar(index, &cnt);
        
        auto bmap = to.make_min_barmap((char*)ptr.get(),cnt,rowsize);

       auto savecnt = to.update_minbar(bmap);
        DLOG("saved cnt:%d", savecnt);
    
        if (loop == 1) {
            index = 50;
            cnt = 70;//
        }
        if (loop ==2) {
            index = 0;
            cnt = 10;
        }
        if (loop == 3) {
            index = 0;
            cnt = 50;
        }
        if (loop == 4) {
            break;
        }
        
    }
    return 0;
}

int main() {
    TdxFileStore::set_rootpath("C:\\new_jyplug");
    TdxFileStore tdx(Exchange::SH, "000001", BarSize::Day1);
    
    auto files = tdx.get_symbols_under_same_dir();
    for (auto& name : files) {
        tdx.set_contract(name);
    }

    return 0;
}